#!/usr/bin/python
# -*- coding:utf-8 -*-
"""
x in s	True if an item of s is equal to x, else False	(1)
x not in s	False if an item of s is equal to x, else True	(1)
s + t	the concatenation of s and t	(6)
s * n, n * s	equivalent to adding s to itself n times	(2)
s[i]	ith item of s, origin 0	(3)
s[i:j]	slice of s from i to j	(3)(4)
s[i:j:k]	slice of s from i to j with step k	(3)(5)
len(s)	length of s
min(s)	smallest item of s
max(s)	largest item of s
s.index(x)	index of the first occurrence of x in s
s.count(x)	total number of occurrences of x in s
"""
"""
列表操作包含以下函数:
1、cmp(list1, list2)：比较两个列表的元素
2、len(list)：列表元素个数
3、max(list)：返回列表元素最大值
4、min(list)：返回列表元素最小值
5、list(seq)：将元组转换为列表
列表操作包含以下方法:
1、list.append(obj)：在列表末尾添加新的对象
2、list.count(obj)：统计某个元素在列表中出现的次数
3、list.extend(seq)：在列表末尾一次性追加另一个序列中的多个值（用新列表扩展原来的列表）
4、list.index(obj)：从列表中找出某个值第一个匹配项的索引位置
5、list.insert(index, obj)：将对象插入列表
6、list.pop(obj=list[-1])：移除列表中的一个元素（默认最后一个元素），并且返回该元素的值
7、list.remove(obj)：移除列表中某个值的第一个匹配项
8、list.reverse()：反向列表中元素
9、list.sort([func])：对原列表进行排序
"""
list_tmp = [1, 2, 5, 9, 7, 7, 9, 'hello']
for l in list_tmp:
    print(l)

print(list_tmp * 2)
print(list_tmp[2:5])
lists = [[i] for i in range(3)]
print(lists[0])

if 'hello world' in list_tmp:
    print("%s is in list" % 'hello world')
else:
    print("%s is not in list" % 'hello world')

del list_tmp[1]
print(list_tmp)

print(list_tmp[-2:])

for i in range(1, 10, 2):
    print(i)
for i in xrange(10):
    print(i)

_str = 'abcdefghijk'
for (index, char) in enumerate(_str):
    print "%s--->%s" % (index, char)

for (index, char) in enumerate(list_tmp):
    print "%s--->%s" % (index, char)

ta = [1, 2, 3]
tb = [9, 8, 7]
tc = ['a', 'b', 'c']
for (a, b, c) in zip(ta, tb, tc):
    print(a, b, c)


def gen():
    num = 100
    yield num
    num *= 8
    yield num
    yield 1000


for i in gen():
    print i

lists = [x ** 2 for x in range(10)]

print(lists)

